package com.axend.aerosense.room.viewmodel;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;

import androidx.lifecycle.MutableLiveData;

import com.alibaba.android.arouter.launcher.ARouter;
import com.axend.aerosense.base.bean.TimeZoneBean;
import com.axend.aerosense.base.utils.SystemUtil;
import com.axend.aerosense.common.bean.PersonSelectItemBean;
import com.axend.aerosense.common.bean.WardSelectItemBean;
import com.axend.aerosense.common.util.StringLengthUtils;
import com.axend.aerosense.room.entity.RoomFallAlertBean;
import com.axend.aerosense.room.entity.RoomSetttingInfoBean;
import com.axend.aerosense.room.entity.RoomEmergencyBean;
import com.axend.aerosense.room.entity.RoomInfoReq;
import com.axend.aerosense.room.entity.RoomWardBean;
import com.blankj.utilcode.util.ToastUtils;
import com.axend.aerosense.base.bean.BaseStringBean;
import com.axend.aerosense.base.bean.RoomTypeBean;
import com.axend.aerosense.base.impl.IBaseView;
import com.axend.aerosense.base.impl.ILoadDataResult;
import com.axend.aerosense.base.impl.IOperationDetailResult;
import com.axend.aerosense.base.impl.IOperationResult;
import com.axend.aerosense.base.storage.MmkvHelper;
import com.axend.aerosense.base.viewmodel.CustomBaseViewModel;
import com.axend.aerosense.common.UrlApi;
import com.axend.aerosense.common.config.Gobal;
import com.axend.aerosense.common.router.RouterActivityPath;
import com.axend.aerosense.common.ui.LoadingDialog;
import com.axend.aerosense.common.util.JsonUtil;
import com.axend.aerosense.network.EasyHttp;
import com.axend.aerosense.network.cache.model.CacheMode;
import com.axend.aerosense.network.callback.ProgressDialogCallBack;
import com.axend.aerosense.network.callback.SimpleCallBack;
import com.axend.aerosense.network.exception.ApiException;
import com.axend.aerosense.room.R;
import com.axend.aerosense.room.entity.FunctionSetInfo;
import com.axend.aerosense.room.entity.RoomSetttingParentBean;
import com.axend.aerosense.room.entity.RoomItemBean;
import com.axend.aerosense.room.entity.RoomTypeChangeBean;
import com.axend.aerosense.room.entity.RoomVipSetBean;
import com.axend.aerosense.room.entity.WardInfoBean;

import java.util.List;

import io.reactivex.disposables.Disposable;

public class RoomSettingInfoViewModel extends CustomBaseViewModel<RoomSetttingParentBean> {
    public MutableLiveData<Boolean> offMode = new MutableLiveData<>(false);
    public MutableLiveData<String> roomName = new MutableLiveData<String>("");
    public MutableLiveData<RoomTypeBean> roomType = new MutableLiveData<RoomTypeBean>();
    public MutableLiveData<PersonSelectItemBean> personSelected = new MutableLiveData<PersonSelectItemBean>();
    public MutableLiveData<WardSelectItemBean> wardSelected = new MutableLiveData<WardSelectItemBean>();
    public MutableLiveData<Boolean> isShowAutoLearn = new MutableLiveData<>(true);  //是否显示自动学习
    public MutableLiveData<Boolean> isCreateMode = new MutableLiveData<>(false);
    public MutableLiveData<Boolean> haveAssure = new MutableLiveData<>(false);  //是否有Assure设备
    public MutableLiveData<Boolean> haveWavve = new MutableLiveData<>(false);  //是否有Wavve设备
    public MutableLiveData<Boolean> fallAlert = new MutableLiveData<>(false);  //是否打开跌倒报警
    public RoomItemBean initEditRoom;
    private Disposable disposable = null;

    public RoomSettingInfoViewModel(IBaseView baseViewImpl, ILoadDataResult<RoomSetttingParentBean> loadDataResultImpl) {
        super(baseViewImpl, loadDataResultImpl);
    }

    public void initData(){

    }

    public void setEditRoomValue(Context context, RoomSetttingInfoBean roomSettingInfo){
        roomName.setValue(roomSettingInfo.getRoomName());
        offMode.setValue(roomSettingInfo.getLeaveHome() != 0);
        personSelected.setValue(new PersonSelectItemBean(roomSettingInfo.getEmergencyUuid(), roomSettingInfo.getEmergencyName(), roomSettingInfo.getEmergencyPhone(), false, ""));
        wardSelected.setValue(new WardSelectItemBean(roomSettingInfo.getWardUuid(), roomSettingInfo.getWardName(), roomSettingInfo.getWardPhone(), false, ""));
//        timeZone.setValue(TimeZoneBean.format(context, roomSettingInfo.getTimeZone()));
        roomType.setValue(new RoomTypeBean(roomSettingInfo.getRoomTypeName(), roomSettingInfo.getRoomType()));
    }

    public void setWard(WardSelectItemBean ward) {
        wardSelected.setValue(ward);
    }

    public void setPerson(PersonSelectItemBean person) {
        personSelected.setValue(person);
    }

    public void setRoomType(RoomTypeBean roomTypeBean){
        roomType.setValue(roomTypeBean);
    }

    public void updateLeaveHome(Activity activity, IOperationResult operationResultListence){
        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        disposable = EasyHttp.post(UrlApi.URL.UpdateLeaveHome.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(new RoomInfoReq(initEditRoom.getRoomUuid())))
                .execute(new ProgressDialogCallBack<BaseStringBean>(LoadingDialog.getProgressDialog(activity)) {
                    @Override
                    public void onError(ApiException e) {
                        dismissProgress();
                        ToastUtils.showShort(e.getMessage());
                        if(null != operationResultListence){
                            operationResultListence.onFail();
                        }
                    }

                    @Override
                    public void onSuccess(BaseStringBean baseStringBean) {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_success);
                        if(null != operationResultListence){
                            operationResultListence.onSuccess();
                        }
                    }

                    @Override
                    public void onTokenExpire() {
                        dismissProgress();
                        if(null != operationResultListence){
                            operationResultListence.onFail();
                        }
                        ToastUtils.showShort(R.string.common_login_first);
                        ARouter.getInstance().build(RouterActivityPath.Login.PAGE_LOGIN_HOME).withBoolean("jumpMainPage", true).greenChannel().navigation();
                    }
                });
    }

    public void deletRoom(Activity activity, IOperationDetailResult<String> operationResultListence){
        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        RoomInfoReq bean = new RoomInfoReq(initEditRoom.getRoomUuid());
        disposable = EasyHttp.post(UrlApi.URL.DelRoom.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(bean))
                .execute(new ProgressDialogCallBack<BaseStringBean>(LoadingDialog.getProgressDialog(activity)) {
                    @Override
                    public void onTokenExpire() {
                        dismissProgress();
                        if(operationResultListence != null){
                            operationResultListence.onFail(Gobal.ERROR_CODE.ERR_LOGIN, "");
                        }
                    }

                    @Override
                    public void onError(ApiException e) {
                        dismissProgress();
                        if(operationResultListence != null){
                            operationResultListence.onFail(e.getCode(), e.getMessage());
                        }
                    }

                    @Override
                    public void onSuccess(BaseStringBean bean) {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_success);
                        if(operationResultListence != null){
                            operationResultListence.onSuccess("");
                        }
                    }
                });
    }

    public void updateFallAlert(Activity activity, boolean checked, IOperationResult result){
        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        disposable = EasyHttp.post(UrlApi.URL.FallAlertSwitch.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(new RoomFallAlertBean(initEditRoom.getRoomUuid(), checked ? 1 : 0)))
                .execute(new ProgressDialogCallBack<BaseStringBean>(LoadingDialog.getProgressDialog(activity)) {
                    @Override
                    public void onError(ApiException e) {
                        dismissProgress();
                        ToastUtils.showShort(e.getMessage());
                        if(null != result){
                            result.onFail();
                        }
                    }

                    @Override
                    public void onSuccess(BaseStringBean baseStringBean) {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_success);
                        if(null != result){
                            result.onSuccess();
                        }
                    }

                    @Override
                    public void onTokenExpire() {
                        dismissProgress();
                        if(null != result){
                            result.onFail();
                        }
                        ToastUtils.showShort(R.string.common_login_first);
                        ARouter.getInstance()
                                .build(RouterActivityPath.Login.PAGE_LOGIN_HOME)
                                .withBoolean("jumpMainPage", true)
                                .greenChannel()
                                .navigation();
                    }
                });
    }

    @Override
    public void onLoad() {
        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        if(TextUtils.isEmpty(token) || null == initEditRoom || TextUtils.isEmpty(initEditRoom.getRoomUuid())){
            return;
        }
        RoomInfoReq bean = new RoomInfoReq(initEditRoom.getRoomUuid());
        disposable = EasyHttp.post(UrlApi.URL.GetRoomSettingInfo.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(bean))
                .execute(new SimpleCallBack<RoomSetttingParentBean>() {
                    @Override
                    public void onTokenExpire() {
                        ARouter.getInstance().build(RouterActivityPath.Login.PAGE_LOGIN_HOME).withBoolean("jumpMainPage", true).greenChannel().navigation();
                    }

                    @Override
                    public void onError(ApiException e) {
                        ToastUtils.showShort(e.getMessage());
                        loadDataFail(e.getMessage());
                    }

                    @Override
                    public void onSuccess(RoomSetttingParentBean bean) {
                        //                        //此处目前是为一个废对象不做处理的
                        loadDataSuccess(bean);
                    }
                });

    }

    /**
     * 创建房间信息
     * @param operationResultListence
     */
    public void createRoom(Activity activity, IOperationResult operationResultListence) {
        if(null == personSelected.getValue() || TextUtils.isEmpty(personSelected.getValue().getEmergencyUuid())){
            ToastUtils.showShort(R.string.room_person_set_tips);
            if(null != operationResultListence) {
                operationResultListence.onFail();
            }
            return;
        };

        if(wardSelected.getValue() == null || TextUtils.isEmpty(wardSelected.getValue().getWardUuid())){
            ToastUtils.showShort(R.string.room_ward_set_tips);
            if(null != operationResultListence) {
                operationResultListence.onFail();
            }
            return;
        };

        TimeZoneBean roomTimeZone = SystemUtil.getTimeZone();

        RoomSetttingInfoBean bean = new RoomSetttingInfoBean(
                null,
                roomName.getValue(),
                roomType.getValue().getRoomType(),
                roomType.getValue().getRoomName(),
                personSelected.getValue().getEmergencyUuid(),
                personSelected.getValue().getEmergencyName(),
                personSelected.getValue().getEmergencyPhone(),
                wardSelected.getValue().getWardUuid(),
                wardSelected.getValue().getWardName(),
                wardSelected.getValue().getWardPhone(),
                roomTimeZone.getRoomTimeZone(),
                roomTimeZone.getRoomTimeZoneArea(),
                0);

        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        disposable = EasyHttp.post(UrlApi.URL.CreateRoom.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(bean))
                .execute(new ProgressDialogCallBack<WardInfoBean>(LoadingDialog.getProgressDialog(activity)) {
                    @Override
                    public void onTokenExpire() {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_login_first);
                        ARouter.getInstance().build(RouterActivityPath.Login.PAGE_LOGIN_HOME).withBoolean("jumpMainPage", true).greenChannel().navigation();
                    }

                    @Override
                    public void onError(ApiException e) {
                        dismissProgress();
                        ToastUtils.showShort(e.getMessage());
                        if(null != operationResultListence){
                            operationResultListence.onFail();
                        }
                    }

                    @Override
                    public void onSuccess(WardInfoBean bean) {
                        dismissProgress();
                        //此处目前是为一个废对象不做处理的
                        if(null != operationResultListence){
                            operationResultListence.onSuccess();
                        }
                    }
                });

    }

    @Override
    protected void onCleared() {
        if(null != disposable && !disposable.isDisposed()){
            disposable.dispose();
            disposable = null;
        }
        super.onCleared();
    }

    public void setRoomType(Activity activity, RoomTypeChangeBean typeBean, IOperationDetailResult<RoomSetttingParentBean> operationResultListence){
        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        if(TextUtils.isEmpty(token)|| null == typeBean){
            return;
        }
        disposable = EasyHttp.post(UrlApi.URL.SetRoomType.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(typeBean))
                .execute(new ProgressDialogCallBack<RoomSetttingParentBean>(LoadingDialog.getProgressDialog(activity)) {
                    @Override
                    public void onTokenExpire() {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_login_first);
                        ARouter.getInstance().build(RouterActivityPath.Login.PAGE_LOGIN_HOME).withBoolean("jumpMainPage", true).greenChannel().navigation();
                    }

                    @Override
                    public void onError(ApiException e) {
                        dismissProgress();
                        ToastUtils.showShort(e.getMessage());
                        if(operationResultListence != null){
                            operationResultListence.onFail(e.getCode(), e.getMessage());
                        }
                    }

                    @Override
                    public void onSuccess(RoomSetttingParentBean bean) {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_success);
                        if(operationResultListence != null){
                            operationResultListence.onSuccess(bean);
                        }
                    }
                });
    }

//    public void setRoomTimeZone(Activity activity, RoomTimeZoneBean timeZone, IOperationDetailResult<String> operationResultListence){
//        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
//        if(TextUtils.isEmpty(token)){
//            return;
//        }
//        disposable = EasyHttp.post(UrlApi.URL.SetRoomPosition.getUrl())
//                .headers("token", token)
//                .cacheMode(CacheMode.NO_CACHE)
//                .upJson(JsonUtil.toJson(timeZone))
//                .execute(new ProgressDialogCallBack<BaseStringBean>(LoadingDialog.getProgressDialog(activity)) {
//                    @Override
//                    public void onTokenExpire() {
//                        dismissProgress();
//                        ARouter.getInstance().build(RouterActivityPath.Login.PAGE_LOGIN_HOME).withBoolean("jumpMainPage", false).greenChannel().navigation();
//                    }
//
//                    @Override
//                    public void onError(ApiException e) {
//                        dismissProgress();
//                        ToastUtils.showShort(e.getMessage());
//                        if(operationResultListence != null){
//                            operationResultListence.onFail(e.getCode(), e.getMessage());
//                        }
//                    }
//
//                    @Override
//                    public void onSuccess(BaseStringBean bean) {
//                        dismissProgress();
//                        ToastUtils.showShort(R.string.common_complete);
//                        if(operationResultListence != null){
//                            operationResultListence.onSuccess("");
//                        }
//                    }
//                });
//    }

    public void setRoomEmergency(Activity activity, RoomEmergencyBean roomEmergencyBean, IOperationDetailResult<String> operationResultListence){
        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        if(TextUtils.isEmpty(token) || null == roomEmergencyBean){
            return;
        }

        disposable = EasyHttp.post(UrlApi.URL.SetRoomEmergency.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(roomEmergencyBean))
                .execute(new ProgressDialogCallBack<BaseStringBean>(LoadingDialog.getProgressDialog(activity)) {
                    @Override
                    public void onTokenExpire() {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_login_first);
                        ARouter.getInstance().build(RouterActivityPath.Login.PAGE_LOGIN_HOME).withBoolean("jumpMainPage", true).greenChannel().navigation();
                    }

                    @Override
                    public void onError(ApiException e) {
                        dismissProgress();
                        ToastUtils.showShort(e.getMessage());
                        if(operationResultListence != null){
                            operationResultListence.onFail(e.getCode(), e.getMessage());
                        }
                    }

                    @Override
                    public void onSuccess(BaseStringBean bean) {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_success);
                        if(operationResultListence != null){
                            operationResultListence.onSuccess("");
                        }
                    }
                });
    }

    public void setRoomWard(Activity activity, RoomWardBean roomWardBean, IOperationDetailResult<String> operationResultListence){
        String token = MmkvHelper.getInstance().getMmkv().decodeString(Gobal.SAVE_KEY.TOKEN);
        if(TextUtils.isEmpty(token) || null == roomWardBean){
            return;
        }

        disposable = EasyHttp.post(UrlApi.URL.SetRoomWard.getUrl())
                .headers("token", token)
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(roomWardBean))
                .execute(new ProgressDialogCallBack<BaseStringBean>(LoadingDialog.getProgressDialog(activity)) {
                    @Override
                    public void onTokenExpire() {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_login_first);
                        ARouter.getInstance().build(RouterActivityPath.Login.PAGE_LOGIN_HOME).withBoolean("jumpMainPage", true).greenChannel().navigation();
                    }

                    @Override
                    public void onError(ApiException e) {
                        dismissProgress();
                        ToastUtils.showShort(e.getMessage());
                        if(operationResultListence != null){
                            operationResultListence.onFail(e.getCode(), e.getMessage());
                        }
                    }

                    @Override
                    public void onSuccess(BaseStringBean bean) {
                        dismissProgress();
                        ToastUtils.showShort(R.string.common_success);
                        if(operationResultListence != null){
                            operationResultListence.onSuccess("");
                        }
                    }
                });
    }

    public String getSimpleRoomName(MutableLiveData<String> name){
        String str = name.getValue();
        return StringLengthUtils.getSimpleString(str, 17);
    }

    public MutableLiveData<Boolean> sleepTimeOutSwitchOpen = new MutableLiveData<Boolean>(false); //卧床不起
    public MutableLiveData<Boolean> roomNightUpAnalysis = new MutableLiveData<Boolean>(false); //起夜分析
    public MutableLiveData<Boolean> roomNightNoBack = new MutableLiveData<Boolean>(false); // 起夜未归
    public MutableLiveData<Boolean> roomOutNoBack = new MutableLiveData<Boolean>(false); //外出未归
    public MutableLiveData<Boolean> roomSedentaryAnalysis = new MutableLiveData<Boolean>(false); //久坐分析
    public MutableLiveData<Boolean> roomRegularLifestyle = new MutableLiveData<Boolean>(false); //作息异常
    public MutableLiveData<Boolean> roomMealAnalysis = new MutableLiveData<Boolean>(false); // 未用餐提醒
    public MutableLiveData<Boolean> roomBathroomDetention = new MutableLiveData<Boolean>(false); //卫浴滞留
    public MutableLiveData<Boolean> roomBathroomUseAnalysis = new MutableLiveData<Boolean>(false); //频繁如厕
    public MutableLiveData<Boolean> roomMotionlessAlert = new MutableLiveData<Boolean>(false);  //原地静止
    public MutableLiveData<Boolean> roomTrendAnalysis = new MutableLiveData<Boolean>(false); // 行动能力分析

    public MutableLiveData<Boolean> roomNoVitalSignals = new MutableLiveData<>(false);  //心跳/呼吸骤停告警
    public MutableLiveData<Boolean> roomBedExitWarning = new MutableLiveData<>(false);  //离床告警
    public MutableLiveData<Boolean> roomAbnormalSleep = new MutableLiveData<>(false);  //作息异常

    /**
     * 检测VIP 开关状态
     * @param setBeans
     * @return
     */
    private boolean isOpen(List<RoomVipSetBean> setBeans){
        if(null != setBeans && setBeans.size() > 0){
            RoomVipSetBean bean = setBeans.get(0);
            if(null != bean && bean.getFunctionSwitch() == 1){
                // 开关开启状态
                return true;
            }
        }
        return false;

    }

    /**
     * 设定VIP相关功能展示状况
     * @param functionSetInfo
     */
    public void setRoomVipTips(FunctionSetInfo functionSetInfo){
        if(null == functionSetInfo){
            sleepTimeOutSwitchOpen.setValue(false);
            roomNightUpAnalysis.setValue(false);
            roomNightNoBack.setValue(false);
            roomOutNoBack.setValue(false);
            roomSedentaryAnalysis.setValue(false);
            roomRegularLifestyle.setValue(false);
            roomMealAnalysis.setValue(false);
            roomBathroomDetention.setValue(false);
            roomBathroomUseAnalysis.setValue(false);
            roomTrendAnalysis.setValue(false);
            roomMotionlessAlert.setValue(false);
            roomNoVitalSignals.setValue(false);
            roomBedExitWarning.setValue(false);
            roomAbnormalSleep.setValue(false);
            return;
        }
        // 卧床不起
        if( isOpen(functionSetInfo.getSleepOvertime())){
            sleepTimeOutSwitchOpen.setValue(true);
        }else{
            sleepTimeOutSwitchOpen.setValue(false);
        }

        //频繁起夜
        if(isOpen(functionSetInfo.getNightRise())){
            roomNightUpAnalysis.setValue(true);
        }else{
            roomNightUpAnalysis.setValue(false);
        }
        // 起夜未归
        if(isOpen(functionSetInfo.getNightRiseNoReturn())){
            roomNightNoBack.setValue(true);
        }else{
            roomNightNoBack.setValue(false);
        }

        // 外出未归
        if(isOpen(functionSetInfo.getEgressNoReturn())){
            roomOutNoBack.setValue(true);
        }else{
            roomOutNoBack.setValue(false);
        }

        // 久坐分析
        if(isOpen(functionSetInfo.getContinuitySit()) || isOpen(functionSetInfo.getAccumulateSit())){
            roomSedentaryAnalysis.setValue(true);
        }else{
            roomSedentaryAnalysis.setValue(false);
        }
        //作息异常
        if(isOpen(functionSetInfo.getWorkAndRest())){
            roomRegularLifestyle.setValue(true);
        }else{
            roomRegularLifestyle.setValue(false);
        }

        //未用餐提醒
        if(isOpen(functionSetInfo.getHaveMeals())){
            roomMealAnalysis.setValue(true);
        }else{
            roomMealAnalysis.setValue(false);
        }

        //卫浴滞留
        if(isOpen(functionSetInfo.getToiletStop())){
            roomBathroomDetention.setValue(true);
        }else{
            roomBathroomDetention.setValue(false);
        }

        //频繁如厕
        if(isOpen(functionSetInfo.getToiletAnalysis())){
            roomBathroomUseAnalysis.setValue(true);
        }else{
            roomBathroomUseAnalysis.setValue(false);
        }

        //原地静止
        if (isOpen(functionSetInfo.getMotionlessAlert())){
            roomMotionlessAlert.setValue(true);
        }else {
            roomMotionlessAlert.setValue(false);
        }

        //行动能力分析
        if(isOpen(functionSetInfo.getTrendAnalysis())){
            roomTrendAnalysis.setValue(true);
        }else{
            roomTrendAnalysis.setValue(false);
        }

        //心跳/呼吸骤停告警
        if (isOpen(functionSetInfo.getNoVitalSignals())){
            roomNoVitalSignals.setValue(true);
        }else {
            roomNoVitalSignals.setValue(false);
        }
        //离床告警
        if (isOpen(functionSetInfo.getBedExitWarning())){
            roomBedExitWarning.setValue(true);
        }else {
            roomBedExitWarning.setValue(false);
        }
        //作息异常
        if (isOpen(functionSetInfo.getAbnormalSleep())){
            roomAbnormalSleep.setValue(true);
        }else {
            roomAbnormalSleep.setValue(false);
        }
    }
}
